feat: Add demo web application showcasing TinyGrid SDK#7
Conversation
Adds a full-stack demo app with: - FastAPI backend wrapping TinyGrid SDK endpoints - React/TypeScript frontend with Vite - Bloomberg/Palantir-inspired dark terminal UI - Docker Compose setup for easy deployment Features: - Dashboard with grid metrics, load forecast, renewables - Settlement point prices with time-series charts - Load and renewable generation forecasts - Historical data query interface Backend endpoints: - /api/load-forecast - Load forecast by zone - /api/wind-forecast - Wind generation forecast - /api/solar-forecast - Solar generation forecast - /api/spp - Settlement point prices - /api/historical - Archive data access Also updates pyrightconfig.json and ruff.toml to exclude the demo from CI checks since it has its own separate dependencies.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
- Integrated prefetching of Day-Ahead LMP data in the FastAPI backend. - Added a new endpoint for real-time fuel mix estimation based on current generation data. - Implemented caching for Day-Ahead LMP data to optimize performance. - Enhanced frontend components with DaisyUI for improved UI consistency and responsiveness. - Updated various components and pages to utilize new data fetching hooks and display real-time information. - Improved error handling and loading states across the application. - Refactored CSS styles to align with DaisyUI theming and removed legacy styles. - Added new utility functions for time formatting and data display consistency.
| { | ||
| "time": time_str, | ||
| "location": str(row.get(loc_col, "")) if loc_col else "", | ||
| "rt_price": float(row.get("Price", row.get("LMP", 0))), |
There was a problem hiding this comment.
Missing NaN handling in price data conversion
The get_lmp_combined endpoint converts price values with float(row.get("Price", row.get("LMP", 0))) without handling NaN values. If the "Price" column exists but contains NaN, row.get() returns the NaN value (the fallback is only used when the key doesn't exist). This differs from dashboard.py which has a safe_float helper that explicitly handles NaN/Inf values. NaN floats can cause JSON serialization errors with the standard library encoder, potentially resulting in 500 responses when the API data contains missing price values.
Additional Locations (1)
| ) | ||
| if not load_df.empty: | ||
| # Get record closest to current hour | ||
| current_hour = datetime.now().hour |
There was a problem hiding this comment.
Inconsistent timezone handling uses server local time
The get_fuel_mix_realtime function correctly creates a Central Time aware timestamp on line 186 using datetime.now(ct), but then inconsistently uses naive datetime.now() without timezone for the API date parameters and current_hour selection. ERCOT data is indexed by Central Time, so if the server runs in a different timezone (common for cloud deployments in UTC), the API request may fetch the wrong date's data and select the wrong hour's row from the DataFrame. For example, a UTC server at 1am on Jan 2nd would request Jan 2nd data and select hour 1, when it should be requesting Jan 1st data and selecting hour 19 Central Time.
Additional Locations (2)
… features - Updated the FastAPI backend to support asynchronous data fetching for load, wind, and solar forecasts. - Added new async wrappers for various ERCOT API methods to improve performance and responsiveness. - Introduced a new endpoint for fetching locational marginal prices (LMP) optimized for grid display. - Enhanced frontend components to utilize new async data fetching hooks, improving loading states and error handling. - Updated the demo application to include a full-stack web application showcasing TinyGrid SDK features with improved UI elements. - Refactored existing components for better code organization and maintainability. - Improved documentation and added new utility functions for better data handling.
| # tinygrid is expected to be installed in the environment | ||
|
|
||
| # CORS and other utilities | ||
| python-multipart>=0.0.6 |
There was a problem hiding this comment.
Missing python-dotenv dependency causes import error
The client.py file imports and uses load_dotenv from the dotenv package at module load time (lines 5 and 10), but python-dotenv is not listed in requirements.txt. This will cause an ImportError when starting the backend, preventing the entire application from running.
Additional Locations (1)
| # I will use asyncio.to_thread for load_forecast but implement others that I DID add. | ||
|
|
||
| # Wait, I see I missed adding get_load_forecast_async in the previous step. | ||
| # I will use asyncio.to_thread for this specific route. |
There was a problem hiding this comment.
Developer notes accidentally committed in production code
Extensive developer thinking notes and internal commentary were accidentally committed. The comments include phrases like "let's check", "I missed adding", "Wait, I see I missed", "I will use asyncio.to_thread for this specific route", and references to editing other files. These are clearly development notes rather than documentation and expose internal implementation decisions that could confuse future maintainers.
Adds a full-stack demo app with:
Features:
Backend endpoints:
Also updates pyrightconfig.json and ruff.toml to exclude the demo from CI checks since it has its own separate dependencies.
Note
Demo application added under
examples/demo/backend/) exposing TinyGrid-powered endpoints: dashboard (/status,/fuel-mix,/renewable,/supply-demand), prices (/spp,/lmp,/lmp-combined,/daily-prices,*-grid), forecasts (/load,/load-forecast,/wind-forecast,/solar-forecast), historical (/historical,/historical/endpoints)tinygrid/pyercotand runninguvicornReact + TypeScript + Vite frontend (
frontend/)Deployment and docs
docker-compose.ymlto run frontend+backend;.env.exampleand comprehensive README for setupCLAUDE.mdexpanded with architecture, demo details, and usage guidanceTooling/housekeeping
.pre-commit-config.yaml: runruff format ..gitignore: addvenv/and Node ignores;examples/.gitignorefor demo artifactsWritten by Cursor Bugbot for commit df50a30. This will update automatically on new commits. Configure here.